﻿namespace Mercury.ParticleEngine
{
    using System;
    using System.Linq;
    using FluentAssertions;
    using Xunit;
    using Xunit.Extensions;

    // ReSharper disable InconsistentNaming

    public class Int32ExtensionsTests
    {
        public class IsPerfectSquareMethod
        {
            [Theory]
            [Trait("Type", "Int32Extensions")]
            [InlineData(new[] { 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024 })]
            public void WhenGivenPerfectSquareValue_ReturnsTrue(Int32[] inputs)
            {
                foreach (var input in inputs)
                {
                    Int32Extensions.IsPerfectSquare(input).Should().BeTrue();
                }
            }

            [Theory]
            [Trait("Type", "Int32Extensions")]
            [InlineData(new[] { 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024 })]
            public void WhenGivenNonPerfectSquareValue_ReturnsFalse(Int32[] exclusions)
            {
                var inputs = Enumerable.Range(0, 1024)
                                       .Except(exclusions);

                foreach (var input in inputs)
                {
                    Int32Extensions.IsPerfectSquare(input).Should().BeFalse();
                }
            }

            [Fact]
            [Trait("Type", "Int32Extensions")]
            public void WhenGivenNegativeValue_ReturnsFalse()
            {
                var inputs = Enumerable.Range(-101, 100);

                foreach (var input in inputs)
                {
                    Int32Extensions.IsPerfectSquare(input).Should().BeFalse();
                }
            }
        }
    }

    // ReSharper restore InconsistentNaming
}